package com.hxzy.springbootrocketconsumer.service;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Service;

/**
 * 消费者消费(MessageExt，不管是字符串还是其它类型都能接收，所以一定要加上)
 * @author Fan
 * RocketMQMessageListener  topic 主题   selectorExpression 选择器表达式  consumerGroup 消费者分组
 * 实现 rocketmq.spring.core RocketMQListener 接口 MessageExt -->message
 * finished
 */
@Service
@RocketMQMessageListener(topic = "RLT_DEMO_TOPIC", selectorExpression = "tag01 || tag02 || tag03 || tag04 ",consumerGroup = "consumer_messageext")
public class ConsumerMessageExtService implements RocketMQListener<MessageExt> {


    @Override
    public void onMessage(MessageExt messageExt) {
        byte[] data=messageExt.getBody();
        //byte转换成 字符串
        System.out.println("MessageExt："+new String(data));
    }

}
